﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ExpressionMediaPlayer;

namespace SSMP
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        public void LoadMedia(string mediaSource, string title, string thumbSource, bool autoLoad, bool autoPlay)
        {
            if (string.IsNullOrEmpty(mediaSource))
                return;

            if (string.IsNullOrEmpty(title))
                title = "Media";

            PlaylistItem playListItem = new PlaylistItem();
            playListItem.MediaSource = new Uri(mediaSource);
            playListItem.Title = title;
            
            if(!string.IsNullOrEmpty(thumbSource))
                playListItem.ThumbSource = new Uri(thumbSource);

            Playlist playList = new Playlist();
            playList.AutoLoad = autoLoad;
            playList.AutoPlay = autoPlay;
            playList.Items.Add(playListItem);

            this.MediaPlayer.Playlist = playList;
        }
    }
}
